<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<?php
		include_once "../inc/docroot.php";
		include_once PATH."inc/class.autores.inc.php";
		$autores = new autores($db);
		if(isset($_GET['imap']))$imap_id = $_GET['imap'];
		if(isset($_GET['edit']))$edit = $_GET['edit'];
		if(isset($_GET['delete']))$delete = $_GET['delete'];

?>
<body>
<div>
   <div class="autores_header">
<?php
       if(  !empty($_POST['host']) && !empty($_POST['port']) && !empty($_POST['name'])&& isset($imap_id) && isset($edit) && $edit == 1) {
        	echo "<br /><br />";
			echo $autores->editimap($imap_id);
			?>
			<script>
			window.opener.location.reload();
			window.close();
            </script>
            <?php
	   }
	   else if( !empty($_POST['host']) && !empty($_POST['port']) && !empty($_POST['name']) ) {
        	echo "<br /><br />";
			echo $autores->addimap();?>
			<script>
			window.opener.location.reload();
            </script>
            <?php
	   }
	   else {
    		echo "<br />";
    		echo "<br />";
   			echo "<label>Please fill all the fields.</label>";
		}
		echo "<br />";
		echo "<br />";

		if(isset($imap_id) && isset($edit) && $edit == 0){
			echo "<label> EDIT IMAP: " .$imap_id."</label>";
		}
		else {
			echo "<label> ADD A NEW IMAP</label>";
		}
?>
	  </div>
  <form method="post" action="addnewimap.php<?php if(isset($imap_id) && isset($edit)) echo "?imap=".$imap_id."&edit=1";?>" name="addimapform" id="addimapform">
    <div style="font-size:9px;" align="center">
      <br />
      <br />
      <input type="text" name="name" id="name" style="text-align:center"/>
      <label for="name">Name</label>
      <br />
      <br />
      <input type="text" name="host" id="host" style="text-align:center"/>
      <label for="host">Host</label>
      <br />
      <br />
      	<input type="text" name="port" id="port" width="60" style="width: 60px; text-align:center"/>
      	<label for="port" width="60" style="width: 60px">Port</label>
      <br />
      <br />
      <select name="charset" id="charset" width="75" style="width: 75px; height:20px; font-size:15px;" height="20">
  			<option value="utf-8">UTF</option>
      </select></br>
      <label for="charset">Charset</label>
      <br />
      <br />
 	  <select name="secure" id="secure" width="75" style="width: 75px; height:20px; font-size:15px;" height="20">
  			<option value="ssl">SSL</option>
  			<option value="tls">TLS</option>
      </select></br>
      <label for="secure">Secure</label>
      <br />
      <br />
      <br />
      <br/ >
      <input type="submit" name="addimapinput" id="addimapinput" value="Save IMAP" class="btn btn--blue btn--m" />
    </div>
  </form>
</div>
</body>
